package apis

import (
	"github.com/gin-gonic/gin"
	"tylnmall/service"
	"net/http"
	"common/logger"
)

func ImgApi(c *gin.Context){
	cid,uid := service.DemoCodeCaptchaCreate()
	//fmt.Printf(cid,uid)
	//c.JSON(http.StatusOK,gin.H{"c":C})
	c.JSON(http.StatusOK,gin.H{"cid":cid,"uid":uid})
}

func UseImgApi(c *gin.Context){
	type param struct {
		Id string`json:"id" form:"id"`
		Val string`json:"val" form:"val"`
	}
	var p param
	var err error
	if err = c.Bind(&p); err != nil {
		logger.Debug("Invalid request param ", err)
		return
	}
	c.JSON(http.StatusOK,gin.H{"status":service.DemoCodeCaptchaUse(p.Val,p.Id)})
}
